#ifndef _RECT_H_
#define _RECT_H_

namespace fe
{
    template<typename T>
    class Rect
    {
    public:
        Rect(T x,T y, T w, T h) {
            this->x = x;
            this->y = y;
            this->h = h;
            this->w = w;
        }
        Rect() { }

        T x, y, w, h;

        inline bool contains(T ox, T oy) {
            return (ox >= x &&
                    ox <= x + w &&
                    oy >= y &&
                    oy <= y + h);
        }

        inline bool contains(Rect<T>& other){
            return
            (    x + other.w >= other.x
            &&   x - other.w <= other.x
            &&   y + other.h >= other.y
            &&   y - other.h <= other.y);
        }

        inline bool contains(T ox, T oy, T ow, T oh) {
            return (
                 x + ow >= ox
            &&   x - ow <= ox
            &&   y + oh >= oy
            &&   y - oh <= oy  );
        }
    };
    typedef Rect<float> RectF;
    typedef Rect<int> RectI;
}

#endif
